<?php

ob_start();
session_start();
$id_member = $_SESSION["id_member"];
$depart = $_SESSION["departid"];
ob_start();

include("../connect.php");

$GrpId = $_POST["grpId"];
$TypeGrpId = $_POST["typeGrpId"];
$Datefinis = $_POST["txtDatefinis"];
$myDatefinis =date('Y-m-d H:i:s', strtotime($Datefinis));



if (!empty($GrpId)) {

    $sqlUpGra = "UPDATE `graphic` SET 
        `grpStatus` = 'action' ,
        grpDateFinish = '$myDatefinis'
WHERE `graphic`.`grpId` = $GrpId ";

    mysql_query($sqlUpGra);


    $inUpgrapic = "INSERT INTO  `graphicup` (
`grupId` ,
`grpId` ,
`typeGrpId` ,
`id_member` ,
`grupDate` ,
`de_id`
)
VALUES (
NULL ,  '$GrpId',  '$TypeGrpId',  '$id_member', NOW() ,  '$depart'
)
";
    mysql_query($inUpgrapic);
} else {

    header("location:\requiGraphic.php");
}
if (mysql_query) {
     echo "<script language='javascript'>
			   alert('Complete');
			   setTimeout(\"parent.$.fancybox.close()\",1000); 
			  </script>";
    echo "<meta http-equiv='refresh' content='5; url=\requiGraphic.php'>";
} else {
    echo mysql_error();
}
?>